<?php
/*
 *author:Yangligao
 *Date:2013-9-25
 */
require '../../Config.php';
$flag = $_GET['flag'];
$adminModel = new AdminModel();
if($flag == 'ajax'){
	$id = $_GET['id'];
	
	$res = $adminModel->admin_select("admin_power,admin_id","where admin_id=$id");
	$arr['admin_id'] = $res[0]['admin_id'];
	$arr['insert'] = $res[0]['admin_power'][0];
	$arr['del'] = $res[0]['admin_power'][1];
	$arr['update'] = $res[0]['admin_power'][2];
	echo json_encode($arr);

	
}else if($flag == 'updatePower'){
	printArr($_POST);
	$arr['admin_id'] = $_POST['admin_id'];
	$arr['admin_power'] = "";
	if(!isset($_POST['insert'])){
		$arr['admin_power'] .= "0";
	}else{
		$arr['admin_power'] .= $_POST['insert'];
	}
	
	if(!isset($_POST['del'])){
		$arr['admin_power'] .= "0";
	}else{
		$arr['admin_power'] .= $_POST['del'];
	}
	
	if(!isset($_POST['update'])){
		$arr['admin_power'] .= "0";
	}else{
		$arr['admin_power'] .= $_POST['update'];
	}
	
	$res = $adminModel->admin_update($arr);
	
	if($res){
		jump('权限修改成功！', $_SERVER['HTTP_REFERER']);
	}else{
		alertInfo('权限修改失败！', $_SERVER['HTTP_REFERER']);
	}
}

?>
